package iostream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class InODemo3 {
    public static void main(String[] args){
        //将new 1.txt复制到a.txt
        //读取 new 1.txt
        FileInputStream fis = null;
        FileOutputStream fos = null;
        try {
            System.out.println("开始复制");
            long start = System.currentTimeMillis();
            fis = new FileInputStream("D:\\develop\\idea\\javase-code\\day09-code\\src\\file\\a.txt");
            //写入
            fos = new FileOutputStream("D:\\develop\\idea\\javase-code\\day09-code\\src\\file\\b.txt");

            byte[] car = new byte[1024];
            int len;
            while ((len = fis.read(car)) != -1){
                fos.write(car,0,len);
            }
            long end = System.currentTimeMillis();
            System.out.println("复制完毕，耗时：" + (end - start) + "毫秒");
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            try {
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
